package com.example.base.demo.i18n;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author TangDan
 * @version 1.0
 * @since 2023/3/7
 */
@ControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(RuntimeException.class)
    @ResponseBody
    public Result handleException(RuntimeException e) {
        return Result.error("500", MessageSourceUtils.getMsg(e.getMessage()));
    }
}
